home *** CD-ROM | disk | FTP | other *** search
- package com.sun.xml.parser;
-
- import com.sun.xml.util.XmlChars;
- import java.io.IOException;
- import java.net.URL;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Locale;
- import java.util.Vector;
- import org.xml.sax.DTDHandler;
- import org.xml.sax.DocumentHandler;
- import org.xml.sax.EntityResolver;
- import org.xml.sax.ErrorHandler;
- import org.xml.sax.InputSource;
- import org.xml.sax.Locator;
- import org.xml.sax.SAXException;
- import org.xml.sax.SAXParseException;
-
- public class Parser implements org.xml.sax.Parser {
- // $FF: renamed from: in com.sun.xml.parser.InputEntity
- private InputEntity field_0;
- private AttributeListImpl attTmp;
- private StringBuffer strTmp;
- private char[] nameTmp;
- private NameCache nameCache;
- private char[] charTmp = new char[2];
- private boolean isValidating = false;
- private boolean fastStandalone = false;
- private boolean isInAttribute = false;
- private boolean inExternalPE;
- private boolean doLexicalPE;
- private boolean donePrologue;
- private boolean isStandalone;
- private String rootElementName;
- private boolean ignoreDeclarations;
- private SimpleHashtable elements = new SimpleHashtable(47);
- private SimpleHashtable params = new SimpleHashtable(7);
- Hashtable notations = new Hashtable(7);
- SimpleHashtable entities = new SimpleHashtable(17);
- private DocumentHandler docHandler;
- private DTDHandler dtdHandler;
- private EntityResolver resolver;
- private ErrorHandler errHandler;
- private Locale locale;
- private Locator locator = new DocLocator(this);
- private DtdEventListener dtdListener;
- private LexicalEventListener lexicalListener;
- private static final boolean supportValidation = true;
- static final String strANY = "ANY";
- static final String strEMPTY = "EMPTY";
- private static final ListenerBase defaultHandler = new ListenerBase();
- private static final String XmlLang = "xml:lang";
- static final Catalog messages = new Catalog();
- // $FF: synthetic field
- static Class class$com$sun$xml$parser$Parser;
-
- public Parser() {
- this.setHandlers();
- }
-
- // $FF: synthetic method
- static InputEntity access$0(Parser var0) {
- return var0.field_0;
- }
-
- void afterDocument() {
- }
-
- void afterRoot() throws SAXException {
- }
-
- private void builtin(String var1, String var2) {
- InternalEntity var3 = new InternalEntity(var1, var2.toCharArray());
- this.entities.put(var1, var3);
- }
-
- public Locale chooseLocale(String[] var1) throws SAXException {
- Locale var2 = messages.chooseLocale(var1);
- if (var2 != null) {
- this.setLocale(var2);
- }
-
- return var2;
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- private void content(ElementDecl var1, boolean var2, ElementValidator var3) throws IOException, SAXException {
- while(true) {
- if (this.field_0.peekc('<')) {
- if (this.maybeElement(var3)) {
- continue;
- }
-
- if (this.field_0.peekc('/')) {
- return;
- }
-
- if (this.maybeComment(true) || this.maybePI(true) || this.field_0.unparsedContent(this.docHandler, var3, var1 != null && var1.ignoreWhitespace, this.isStandalone && this.isValidating && !var1.isFromInternalSubset ? "V-023" : null)) {
- continue;
- }
-
- char var4 = this.getc();
- this.fatal("P-079", new Object[]{Integer.toHexString(var4), new Character(var4)});
- }
-
- if (var1 != null && var1.ignoreWhitespace && this.field_0.ignorableWhitespace(this.docHandler)) {
- if (this.isValidating && this.isStandalone && !var1.isFromInternalSubset) {
- this.error("V-011", new Object[]{var1.name});
- }
- } else if (!this.field_0.parsedContent(this.docHandler, var3)) {
- if (!this.field_0.isEOF()) {
- if (this.maybeReferenceInContent(var1, var3)) {
- continue;
- }
-
- throw new InternalError();
- }
-
- if (!var2) {
- this.fatal("P-035");
- }
-
- return;
- }
- }
- }
-
- private boolean defaultAttributes(AttributeListImpl var1, ElementDecl var2) throws SAXException {
- boolean var3 = false;
- Enumeration var4 = var2.attributes.keys();
-
- while(var4.hasMoreElements()) {
- String var5 = (String)var4.nextElement();
- String var6 = var1.getValue(var5);
- if (var6 == null) {
- AttributeDecl var7 = (AttributeDecl)var2.attributes.get(var5);
- if (this.isValidating && var7.isRequired) {
- this.error("V-009", new Object[]{var5});
- }
-
- if (var7.defaultValue != null) {
- if (this.isValidating && this.isStandalone && !var7.isFromInternalSubset) {
- this.error("V-010", new Object[]{var5});
- }
-
- var1.addAttribute(var5, var7.type, var7.defaultValue, var7.defaultValue, false);
- var3 = true;
- }
- }
- }
-
- return var3;
- }
-
- void error(String var1, Object[] var2) throws SAXException {
- SAXParseException var3 = new SAXParseException(messages.getMessage(this.locale, var1, var2), this.locator);
- this.errHandler.error(var3);
- }
-
- private void expandEntityInContent(ElementDecl var1, String var2, ElementValidator var3) throws SAXException, IOException {
- Object var4 = this.entities.get(var2);
- InputEntity var5 = this.field_0;
- if (var4 == null) {
- this.fatal("P-014", new Object[]{var2});
- }
-
- if (var4 instanceof InternalEntity) {
- InternalEntity var6 = (InternalEntity)var4;
- if (this.isValidating && this.isStandalone && !var6.isFromInternalSubset) {
- this.error("V-002", new Object[]{var2});
- }
-
- this.pushReader(var6.buf, var2, true);
- this.content(var1, true, var3);
- if (this.field_0 != var5 && !this.field_0.isEOF()) {
- while(this.field_0.isInternal()) {
- this.field_0 = this.field_0.pop();
- }
-
- this.fatal("P-052", new Object[]{var2});
- }
-
- this.lexicalListener.endParsedEntity(var2, true);
- this.field_0 = this.field_0.pop();
- } else {
- if (!(var4 instanceof ExternalEntity)) {
- throw new InternalError(var2);
- }
-
- ExternalEntity var7 = (ExternalEntity)var4;
- if (var7.notation != null) {
- this.fatal("P-053", new Object[]{var2});
- }
-
- if (this.isValidating && this.isStandalone && !var7.isFromInternalSubset) {
- this.error("V-002", new Object[]{var2});
- }
-
- this.externalParsedEntity(var1, var7, var3);
- }
-
- }
-
- private void expandEntityInLiteral(String var1, SimpleHashtable var2, boolean var3) throws SAXException, IOException {
- Object var4 = var2.get(var1);
- if (var4 instanceof InternalEntity) {
- InternalEntity var5 = (InternalEntity)var4;
- if (this.isValidating && this.isStandalone && !var5.isFromInternalSubset) {
- this.error("V-002", new Object[]{var1});
- }
-
- this.pushReader(var5.buf, var1, var5.isPE ^ true);
- } else if (var4 instanceof ExternalEntity) {
- if (!var3) {
- this.fatal("P-013", new Object[]{var1});
- }
-
- this.pushReader((ExternalEntity)var4);
- } else if (var4 == null) {
- this.fatal(var2 == this.params ? "V-022" : "P-014", new Object[]{var1});
- }
-
- }
-
- private void externalParameterEntity(ExternalEntity var1) throws IOException, SAXException {
- if (!this.isStandalone || !this.fastStandalone) {
- this.inExternalPE = true;
-
- try {
- this.pushReader(var1);
- } catch (IOException var5) {
- this.fatal("P-082", new Object[]{var1.systemId}, var5);
- }
-
- InputEntity var2 = this.field_0;
-
- try {
- this.maybeTextDecl();
- } catch (IOException var4) {
- this.field_0 = this.field_0.pop();
- this.fatal("P-082", new Object[]{var1.systemId}, var4);
- }
-
- while(!var2.isEOF()) {
- if (this.field_0.isEOF()) {
- this.field_0 = this.field_0.pop();
- } else {
- this.doLexicalPE = false;
- if (!this.maybeWhitespace() && !this.maybePEReference()) {
- this.doLexicalPE = true;
- if (!this.maybeMarkupDecl() && !this.maybeConditionalSect()) {
- break;
- }
- }
- }
- }
-
- if (!var2.isEOF()) {
- this.fatal("P-059", new Object[]{this.field_0.getName()});
- }
-
- this.field_0 = this.field_0.pop();
- this.inExternalPE = this.field_0.isDocument() ^ true;
- this.doLexicalPE = false;
- }
- }
-
- private boolean externalParsedEntity(ElementDecl var1, ExternalEntity var2, ElementValidator var3) throws IOException, SAXException {
- if (!this.pushReader(var2)) {
- if (!this.isInAttribute) {
- this.lexicalListener.endParsedEntity(var2.name, false);
- }
-
- return false;
- } else {
- this.maybeTextDecl();
- this.content(var1, true, var3);
- if (!this.field_0.isEOF()) {
- this.fatal("P-058", new Object[]{var2.name});
- }
-
- this.field_0 = this.field_0.pop();
- if (!this.isInAttribute) {
- this.lexicalListener.endParsedEntity(var2.name, true);
- }
-
- return true;
- }
- }
-
- private void fatal(String var1) throws SAXException {
- this.fatal(var1, (Object[])null, (Exception)null);
- }
-
- private void fatal(String var1, Object[] var2) throws SAXException {
- this.fatal(var1, var2, (Exception)null);
- }
-
- private void fatal(String var1, Object[] var2, Exception var3) throws SAXException {
- SAXParseException var4 = new SAXParseException(messages.getMessage(this.locale, var1, var2), this.locator, var3);
- this.errHandler.fatalError(var4);
- throw var4;
- }
-
- public DTDHandler getDTDHandler() {
- return this.dtdHandler;
- }
-
- public DocumentHandler getDocumentHandler() {
- return this.docHandler;
- }
-
- public EntityResolver getEntityResolver() {
- return this.resolver;
- }
-
- public ErrorHandler getErrorHandler() {
- return this.errHandler;
- }
-
- private ContentModel getFrequency(ContentModel var1) throws IOException, SAXException {
- char var2 = this.getc();
- if (var2 != '?' && var2 != '+' && var2 != '*') {
- this.ungetc();
- return var1;
- } else {
- this.strTmp.append(var2);
- if (var1 == null) {
- return null;
- } else if (var1.type == 0) {
- var1.type = var2;
- return var1;
- } else {
- return this.newContentModel(var2, var1);
- }
- }
- }
-
- public Locale getLocale() {
- return this.locale;
- }
-
- private String getMarkupDeclname(String var1, boolean var2) throws IOException, SAXException {
- this.whitespace(var1);
- String var3 = this.maybeGetName();
- if (var3 == null) {
- this.fatal("P-005", new Object[]{messages.getMessage(this.locale, var1)});
- }
-
- return var3;
- }
-
- private void getMixed(String var1, InputEntity var2) throws IOException, SAXException {
- this.maybeWhitespace();
- if (!this.peek(")*") && !this.peek(")")) {
- Vector var3 = null;
- if (this.isValidating) {
- var3 = new Vector();
- }
-
- while(this.peek("|")) {
- this.strTmp.append('|');
- this.maybeWhitespace();
- String var4 = this.maybeGetName();
- if (var4 == null) {
- this.fatal("P-042", new Object[]{var1, Integer.toHexString(this.getc())});
- }
-
- if (this.isValidating) {
- if (var3.contains(var4)) {
- this.error("V-015", new Object[]{var4});
- } else {
- var3.addElement(var4);
- }
- }
-
- this.strTmp.append(var4);
- this.maybeWhitespace();
- }
-
- if (!this.peek(")*")) {
- this.fatal("P-043", new Object[]{var1, new Character(this.getc())});
- }
-
- if (this.isValidating && this.field_0 != var2) {
- this.error("V-014", new Object[]{var1});
- }
-
- this.strTmp.append(')');
- } else {
- if (this.isValidating && this.field_0 != var2) {
- this.error("V-014", new Object[]{var1});
- }
-
- this.strTmp.append(')');
- }
- }
-
- private String getMixedOrChildren(ElementDecl var1) throws IOException, SAXException {
- this.strTmp = new StringBuffer();
- this.nextChar('(', "F-028", var1.name);
- InputEntity var2 = this.field_0;
- this.maybeWhitespace();
- this.strTmp.append('(');
- if (this.peek("#PCDATA")) {
- this.strTmp.append("#PCDATA");
- this.getMixed(var1.name, var2);
- var1.ignoreWhitespace = false;
- } else {
- var1.model = this.getcps(var1.name, var2);
- var1.ignoreWhitespace = true;
- }
-
- return this.strTmp.toString();
- }
-
- private String getNmtoken() throws SAXException, IOException {
- char var1 = this.getc();
- if (!XmlChars.isNameChar(var1)) {
- this.fatal("P-006", new Object[]{new Character(var1)});
- }
-
- return this.nameCharString(var1).name;
- }
-
- private String getQuotedString(String var1, String var2) throws IOException, SAXException {
- char var3 = this.field_0.getc();
- if (var3 != '\'' && var3 != '"') {
- this.fatal("P-015", new Object[]{messages.getMessage(this.locale, var1, new Object[]{var2})});
- }
-
- this.strTmp = new StringBuffer();
-
- char var4;
- while((var4 = this.field_0.getc()) != var3) {
- this.strTmp.append(var4);
- }
-
- return this.strTmp.toString();
- }
-
- private char getc() throws IOException, SAXException {
- if (this.inExternalPE && this.doLexicalPE) {
- while(this.field_0.isEOF()) {
- if (!this.field_0.isInternal() && (!this.doLexicalPE || this.field_0.isDocument())) {
- this.fatal("P-064", new Object[]{this.field_0.getName()});
- } else {
- this.field_0 = this.field_0.pop();
- }
- }
-
- char var4;
- if ((var4 = this.field_0.getc()) == '%' && this.doLexicalPE) {
- String var2 = this.maybeGetName();
- if (var2 == null) {
- this.fatal("P-011");
- }
-
- this.nextChar(';', "F-021", var2);
- Object var3 = this.params.get(var2);
- this.pushReader(" ".toCharArray(), (String)null, false);
- if (var3 instanceof InternalEntity) {
- this.pushReader(((InternalEntity)var3).buf, var2, false);
- } else if (var3 instanceof ExternalEntity) {
- this.pushReader((ExternalEntity)var3);
- } else {
- if (var3 != null) {
- throw new InternalError();
- }
-
- this.fatal("V-022");
- }
-
- this.pushReader(" ".toCharArray(), (String)null, false);
- return this.field_0.getc();
- } else {
- return var4;
- }
- } else {
- char var1 = this.field_0.getc();
- if (var1 == '%' && this.doLexicalPE) {
- this.fatal("P-080");
- }
-
- return var1;
- }
- }
-
- private ContentModel getcps(String var1, InputEntity var2) throws IOException, SAXException {
- boolean var3 = false;
- char var4 = 0;
- ContentModel var7 = null;
- ContentModel var6 = null;
- ContentModel var5 = null;
-
- do {
- String var8 = this.maybeGetName();
- if (var8 != null) {
- this.strTmp.append(var8);
- var7 = this.getFrequency(this.newContentModel(var8));
- } else if (this.peek("(")) {
- InputEntity var9 = this.field_0;
- this.strTmp.append('(');
- this.maybeWhitespace();
- var7 = this.getFrequency(this.getcps(var1, var9));
- } else {
- this.fatal(var4 == 0 ? "P-039" : (var4 == ',' ? "P-037" : "P-038"), new Object[]{new Character(this.getc())});
- }
-
- this.maybeWhitespace();
- if (var3) {
- char var10 = this.getc();
- if (var6 != null) {
- var6.next = this.newContentModel(var4, var7);
- var6 = var6.next;
- }
-
- if (var10 == var4) {
- this.strTmp.append(var4);
- this.maybeWhitespace();
- continue;
- }
-
- if (var10 == ')') {
- this.ungetc();
- continue;
- }
-
- this.fatal(var4 == 0 ? "P-041" : "P-040", new Object[]{new Character(var10), new Character(var4)});
- } else {
- var4 = this.getc();
- if (var4 != '|' && var4 != ',') {
- var6 = var7;
- var5 = var7;
- this.ungetc();
- continue;
- }
-
- var3 = true;
- var5 = var6 = this.newContentModel(var4, var7);
- this.strTmp.append(var4);
- }
-
- this.maybeWhitespace();
- } while(!this.peek(")"));
-
- if (this.isValidating && this.field_0 != var2) {
- this.error("V-014", new Object[]{var1});
- }
-
- this.strTmp.append(')');
- return this.getFrequency(var5);
- }
-
- private void init() {
- this.field_0 = null;
- this.attTmp = new AttributeListImpl();
- this.strTmp = new StringBuffer();
- this.nameTmp = new char[20];
- this.nameCache = new NameCache();
- this.isStandalone = false;
- this.rootElementName = null;
- this.isInAttribute = false;
- this.inExternalPE = false;
- this.doLexicalPE = false;
- this.donePrologue = false;
- this.entities.clear();
- this.notations.clear();
- this.params.clear();
- this.elements.clear();
- this.ignoreDeclarations = false;
- this.builtin("amp", "&");
- this.builtin("lt", "<");
- this.builtin("gt", ">");
- this.builtin("quot", "\"");
- this.builtin("apos", "'");
- if (this.locale == null) {
- this.locale = Locale.getDefault();
- }
-
- if (this.resolver == null) {
- this.resolver = new Resolver();
- }
-
- this.setHandlers();
- }
-
- public boolean isFastStandalone() {
- return this.fastStandalone;
- }
-
- private boolean isXmlLang(String var1) {
- if (var1.length() < 2) {
- return false;
- } else {
- char var3 = var1.charAt(1);
- int var2;
- if (var3 == '-') {
- var3 = var1.charAt(0);
- if (var3 != 'i' && var3 != 'I' && var3 != 'x' && var3 != 'X') {
- return false;
- }
-
- var2 = 1;
- } else {
- if ((var3 < 'a' || var3 > 'z') && (var3 < 'A' || var3 > 'Z')) {
- return false;
- }
-
- var3 = var1.charAt(0);
- if ((var3 < 'a' || var3 > 'z') && (var3 < 'A' || var3 > 'Z')) {
- return false;
- }
-
- var2 = 2;
- }
-
- while(var2 < var1.length()) {
- var3 = var1.charAt(var2);
- if (var3 != '-') {
- break;
- }
-
- while(true) {
- ++var2;
- if (var2 >= var1.length()) {
- break;
- }
-
- var3 = var1.charAt(var2);
- if ((var3 < 'a' || var3 > 'z') && (var3 < 'A' || var3 > 'Z')) {
- break;
- }
- }
- }
-
- return var1.length() == var2 && var3 != '-';
- }
- }
-
- private boolean maybeAttlistDecl() throws IOException, SAXException {
- InputEntity var1 = this.peekDeclaration("!ATTLIST");
- if (var1 == null) {
- return false;
- } else {
- String var2 = this.getMarkupDeclname("F-016", true);
- ElementDecl var3 = (ElementDecl)this.elements.get(var2);
- if (var3 == null) {
- var3 = new ElementDecl(var2);
- if (!this.ignoreDeclarations) {
- this.elements.put(var2, var3);
- }
- }
-
- this.maybeWhitespace();
-
- for(; !this.peek(">"); this.maybeWhitespace()) {
- var2 = this.maybeGetName();
- if (var2 == null) {
- this.fatal("P-044", new Object[]{new Character(this.getc())});
- }
-
- this.whitespace("F-001");
- AttributeDecl var4 = new AttributeDecl(var2);
- var4.isFromInternalSubset = this.inExternalPE ^ true;
- if (this.peek("CDATA")) {
- var4.type = "CDATA";
- } else if (this.peek("IDREFS")) {
- var4.type = "IDREFS";
- } else if (this.peek("IDREF")) {
- var4.type = "IDREF";
- } else if (this.peek("ID")) {
- var4.type = "ID";
- if (var3.id != null) {
- if (this.isValidating) {
- this.error("V-016", new Object[]{var3.id});
- }
- } else {
- var3.id = var2;
- }
- } else if (this.peek("ENTITY")) {
- var4.type = "ENTITY";
- } else if (this.peek("ENTITIES")) {
- var4.type = "ENTITIES";
- } else if (this.peek("NMTOKENS")) {
- var4.type = "NMTOKENS";
- } else if (this.peek("NMTOKEN")) {
- var4.type = "NMTOKEN";
- } else if (this.peek("NOTATION")) {
- var4.type = "NOTATION";
- this.whitespace("F-002");
- this.nextChar('(', "F-029", (String)null);
- this.maybeWhitespace();
- Vector var10 = new Vector();
-
- do {
- if ((var2 = this.maybeGetName()) == null) {
- this.fatal("P-068");
- }
-
- if (this.isValidating && this.notations.get(var2) == null) {
- this.notations.put(var2, var2);
- }
-
- var10.addElement(var2);
- this.maybeWhitespace();
- if (this.peek("|")) {
- this.maybeWhitespace();
- }
- } while(!this.peek(")"));
-
- var4.values = new String[var10.size()];
-
- for(int var11 = 0; var11 < var10.size(); ++var11) {
- var4.values[var11] = (String)var10.elementAt(var11);
- }
- } else if (this.peek("(")) {
- var4.type = "ENUMERATION";
- this.maybeWhitespace();
- Vector var5 = new Vector();
-
- do {
- var2 = this.getNmtoken();
- var5.addElement(var2);
- this.maybeWhitespace();
- if (this.peek("|")) {
- this.maybeWhitespace();
- }
- } while(!this.peek(")"));
-
- var4.values = new String[var5.size()];
-
- for(int var6 = 0; var6 < var5.size(); ++var6) {
- var4.values[var6] = (String)var5.elementAt(var6);
- }
- } else {
- this.fatal("P-045", new Object[]{var2, new Character(this.getc())});
- }
-
- this.whitespace("F-003");
- if (this.peek("#REQUIRED")) {
- var4.isRequired = true;
- } else if (this.peek("#FIXED")) {
- if (this.isValidating && var4.type == "ID") {
- this.error("V-017", new Object[]{var4.name});
- }
-
- var4.isFixed = true;
- this.whitespace("F-004");
- this.parseLiteral(false);
- if (var4.type != "CDATA") {
- var4.defaultValue = this.normalize(false);
- } else {
- var4.defaultValue = this.strTmp.toString();
- }
-
- if (var4.type != "CDATA") {
- this.validateAttributeSyntax(var4, var4.defaultValue);
- }
- } else if (!this.peek("#IMPLIED")) {
- if (this.isValidating && var4.type == "ID") {
- this.error("V-018", new Object[]{var4.name});
- }
-
- this.parseLiteral(false);
- if (var4.type != "CDATA") {
- var4.defaultValue = this.normalize(false);
- } else {
- var4.defaultValue = this.strTmp.toString();
- }
-
- if (var4.type != "CDATA") {
- this.validateAttributeSyntax(var4, var4.defaultValue);
- }
- }
-
- if ("xml:lang".equals(var4.name) && var4.defaultValue != null && !this.isXmlLang(var4.defaultValue)) {
- this.error("P-033", new Object[]{var4.defaultValue});
- }
-
- if (!this.ignoreDeclarations && var3.attributes.get(var4.name) == null) {
- var3.attributes.put(var4.name, var4);
- this.dtdListener.attributeDecl(var3.name, var4.name, var4.type, var4.values, var4.defaultValue, var4.isFixed, var4.isRequired);
- }
- }
-
- if (this.isValidating && var1 != this.field_0) {
- this.error("V-013", (Object[])null);
- }
-
- return true;
- }
- }
-
- private boolean maybeComment(boolean var1) throws IOException, SAXException {
- if (!this.field_0.peek(var1 ? "!--" : "<!--", (char[])null)) {
- return false;
- } else {
- boolean var2 = this.doLexicalPE;
- this.doLexicalPE = false;
- boolean var3 = this.lexicalListener instanceof ListenerBase ^ true;
- if (var3) {
- this.strTmp = new StringBuffer();
- }
-
- while(true) {
- try {
- char var4 = this.getc();
- if (var4 == '-') {
- var4 = this.getc();
- if (var4 == '-') {
- this.nextChar('>', "F-022", (String)null);
- break;
- }
-
- if (var3) {
- this.strTmp.append('-');
- }
-
- this.ungetc();
- } else if (var3) {
- this.strTmp.append((char)var4);
- }
- } catch (EndOfInputException var5) {
- if (this.inExternalPE || !this.donePrologue && this.field_0.isInternal()) {
- if (this.isValidating) {
- this.error("V-021", (Object[])null);
- }
-
- this.field_0 = this.field_0.pop();
- } else {
- this.fatal("P-017");
- }
- }
- }
-
- this.doLexicalPE = var2;
- if (var3) {
- this.lexicalListener.comment(this.strTmp.toString());
- }
-
- return true;
- }
- }
-
- private boolean maybeConditionalSect() throws IOException, SAXException {
- if (!this.peek("<![")) {
- return false;
- } else {
- InputEntity var2 = this.field_0;
- this.maybeWhitespace();
- String var1;
- if ((var1 = this.maybeGetName()) == null) {
- this.fatal("P-046");
- }
-
- this.maybeWhitespace();
- this.nextChar('[', "F-030", (String)null);
- if (!"INCLUDE".equals(var1)) {
- if ("IGNORE".equals(var1)) {
- int var3 = 1;
- this.doLexicalPE = false;
-
- while(var3 > 0) {
- char var4 = this.getc();
- if (var4 == '<') {
- if (this.peek("![")) {
- ++var3;
- }
- } else if (var4 == ']' && this.peek("]>")) {
- --var3;
- }
- }
- } else {
- this.fatal("P-048", new Object[]{var1});
- }
- } else {
- while(true) {
- while(!this.field_0.isEOF() || this.field_0 == var2) {
- if (this.field_0.isEOF()) {
- if (this.isValidating) {
- this.error("V-020", (Object[])null);
- }
-
- this.field_0 = this.field_0.pop();
- }
-
- if (this.peek("]]>")) {
- return true;
- }
-
- this.doLexicalPE = false;
- if (!this.maybeWhitespace() && !this.maybePEReference()) {
- this.doLexicalPE = true;
- if (!this.maybeMarkupDecl() && !this.maybeConditionalSect()) {
- this.fatal("P-047");
- }
- }
- }
-
- this.field_0 = this.field_0.pop();
- }
- }
-
- return true;
- }
- }
-
- private boolean maybeDoctypeDecl() throws IOException, SAXException {
- if (!this.peek("<!DOCTYPE")) {
- return false;
- } else {
- ExternalEntity var1 = null;
- this.rootElementName = this.getMarkupDeclname("F-014", true);
- this.dtdListener.startDtd(this.rootElementName);
- if (this.maybeWhitespace() && (var1 = this.maybeExternalID()) != null) {
- this.dtdListener.externalDtdDecl(var1.publicId, var1.systemId);
- this.maybeWhitespace();
- }
-
- if (this.field_0.peekc('[')) {
- this.field_0.startRemembering();
-
- label70:
- while(true) {
- while(!this.field_0.isEOF() || this.field_0.isDocument()) {
- if (!this.maybeMarkupDecl() && !this.maybePEReference() && !this.maybeWhitespace()) {
- if (!this.peek("<![")) {
- this.dtdListener.internalDtdDecl(this.field_0.rememberText());
- this.nextChar(']', "F-024", (String)null);
- this.maybeWhitespace();
- break label70;
- }
-
- this.fatal("P-028");
- }
- }
-
- this.field_0 = this.field_0.pop();
- }
- }
-
- this.nextChar('>', "F-025", (String)null);
- if (var1 != null) {
- var1.name = "(DOCTYPE)";
- var1.isPE = true;
- this.externalParameterEntity(var1);
- }
-
- this.params.clear();
- this.dtdListener.endDtd();
- Vector var2 = new Vector();
- Enumeration var3 = this.notations.keys();
-
- while(var3.hasMoreElements()) {
- String var4 = (String)var3.nextElement();
- Object var5 = this.notations.get(var4);
- if (var5 == Boolean.TRUE) {
- if (this.isValidating) {
- this.error("V-003", new Object[]{var4});
- }
-
- var2.addElement(var4);
- } else if (var5 instanceof String) {
- if (this.isValidating) {
- this.error("V-004", new Object[]{var4});
- }
-
- var2.addElement(var4);
- }
- }
-
- while(!var2.isEmpty()) {
- Object var6 = var2.firstElement();
- var2.removeElement(var6);
- this.notations.remove(var6);
- }
-
- return true;
- }
- }
-
- private boolean maybeElement(ElementValidator var1) throws IOException, SAXException {
- boolean var4 = false;
- boolean var5 = true;
- NameCacheEntry var2 = this.maybeGetNameCacheEntry();
- if (var2 == null) {
- return false;
- } else {
- if (var1 != null) {
- var1.consume(var2.name);
- }
-
- ElementDecl var3 = (ElementDecl)this.elements.get(var2.name);
- if (this.isValidating) {
- if (var3 == null || var3.contentType == null) {
- this.error("V-005", new Object[]{var2.name});
- var3 = new ElementDecl(var2.name);
- var3.contentType = "ANY";
- this.elements.put(var2.name, var3);
- }
-
- if (var1 == null && this.rootElementName != null && !this.rootElementName.equals(var2.name)) {
- this.error("V-006", new Object[]{var2.name, this.rootElementName});
- }
- }
-
- int var6 = this.field_0.getLineNumber();
-
- for(boolean var7 = this.field_0.maybeWhitespace(); !this.field_0.peekc('>'); var4 = true) {
- if (this.field_0.peekc('/')) {
- var5 = false;
- break;
- }
-
- if (!var7) {
- this.fatal("P-030");
- }
-
- String var8 = this.maybeGetName();
- if (var8 == null) {
- this.fatal("P-031", new Object[]{new Character(this.getc())});
- }
-
- if (this.attTmp.getValue(var8) != null) {
- this.fatal("P-032", new Object[]{var8});
- }
-
- this.field_0.maybeWhitespace();
- this.nextChar('=', "F-026", var8);
- this.field_0.maybeWhitespace();
- this.parseLiteral(false);
- var7 = this.field_0.maybeWhitespace();
- AttributeDecl var9 = var3 == null ? null : (AttributeDecl)var3.attributes.get(var8);
- String var10;
- if (var9 == null) {
- if (this.isValidating) {
- this.error("V-007", new Object[]{var8, var2.name});
- }
-
- var10 = this.strTmp.toString();
- } else {
- if (!"CDATA".equals(var9.type)) {
- var10 = this.normalize(var9.isFromInternalSubset ^ true);
- if (this.isValidating) {
- this.validateAttributeSyntax(var9, var10);
- }
- } else {
- var10 = this.strTmp.toString();
- }
-
- if (this.isValidating && var9.isFixed && !var10.equals(var9.defaultValue)) {
- this.error("V-008", new Object[]{var8, var2.name, var9.defaultValue});
- }
- }
-
- if ("xml:lang".equals(var8) && !this.isXmlLang(var10)) {
- this.error("P-033", new Object[]{var10});
- }
-
- this.attTmp.addAttribute(var8, var9 == null ? "CDATA" : var9.type, var10, var9 == null ? null : var9.defaultValue, true);
- }
-
- if (var3 != null) {
- this.attTmp.setIdAttributeName(var3.id);
- }
-
- if (var3 != null && var3.attributes.size() != 0) {
- var4 = this.defaultAttributes(this.attTmp, var3) || var4;
- }
-
- this.docHandler.startElement(var2.name, this.attTmp);
- if (var4) {
- this.attTmp.clear();
- }
-
- var1 = this.newValidator(var3);
- if (var5) {
- this.content(var3, false, var1);
- if (!this.field_0.peek(var2.name, var2.chars)) {
- this.fatal("P-034", new Object[]{var2.name, new Integer(var6)});
- }
-
- this.field_0.maybeWhitespace();
- }
-
- this.nextChar('>', "F-027", var2.name);
- var1.done();
- this.docHandler.endElement(var2.name);
- return true;
- }
- }
-
- private boolean maybeElementDecl() throws IOException, SAXException {
- InputEntity var1 = this.peekDeclaration("!ELEMENT");
- if (var1 == null) {
- return false;
- } else {
- String var2 = this.getMarkupDeclname("F-015", true);
- ElementDecl var3 = (ElementDecl)this.elements.get(var2);
- boolean var4 = false;
- if (var3 != null) {
- if (var3.contentType != null) {
- if (this.isValidating && var3.contentType != null) {
- this.error("V-012", new Object[]{var2});
- }
-
- var3 = new ElementDecl(var2);
- }
- } else {
- var3 = new ElementDecl(var2);
- if (!this.ignoreDeclarations) {
- this.elements.put(var3.name, var3);
- var4 = true;
- }
- }
-
- var3.isFromInternalSubset = this.inExternalPE ^ true;
- this.whitespace("F-000");
- if (this.peek("EMPTY")) {
- var3.contentType = "EMPTY";
- var3.ignoreWhitespace = true;
- } else if (this.peek("ANY")) {
- var3.contentType = "ANY";
- var3.ignoreWhitespace = false;
- } else {
- var3.contentType = this.getMixedOrChildren(var3);
- }
-
- this.maybeWhitespace();
- char var5 = this.getc();
- if (var5 != '>') {
- this.fatal("P-036", new Object[]{var2, new Character(var5)});
- }
-
- if (this.isValidating && var1 != this.field_0) {
- this.error("V-013", (Object[])null);
- }
-
- if (var4) {
- this.dtdListener.elementDecl(var3.name, var3.contentType);
- }
-
- return true;
- }
- }
-
- private boolean maybeEntityDecl() throws IOException, SAXException {
- InputEntity var1 = this.peekDeclaration("!ENTITY");
- if (var1 == null) {
- return false;
- } else {
- this.doLexicalPE = false;
- this.whitespace("F-005");
- SimpleHashtable var3;
- if (this.field_0.peekc('%')) {
- this.whitespace("F-006");
- var3 = this.params;
- } else {
- var3 = this.entities;
- }
-
- this.ungetc();
- this.doLexicalPE = true;
- String var2 = this.getMarkupDeclname("F-017", false);
- this.whitespace("F-007");
- ExternalEntity var4 = this.maybeExternalID();
- boolean var5 = var3.get(var2) == null;
- if (!var5 && var3 == this.entities) {
- this.warning("P-054", new Object[]{var2});
- }
-
- var5 &= this.ignoreDeclarations ^ true;
- if (var4 == null) {
- this.doLexicalPE = false;
- this.parseLiteral(true);
- this.doLexicalPE = true;
- if (var5) {
- char[] var6 = new char[this.strTmp.length()];
- if (var6.length != 0) {
- this.strTmp.getChars(0, var6.length, var6, 0);
- }
-
- InternalEntity var7 = new InternalEntity(var2, var6);
- var7.isPE = var3 == this.params;
- var7.isFromInternalSubset = this.inExternalPE ^ true;
- var3.put(var2, var7);
- if (var3 == this.entities && !(this.dtdListener instanceof ListenerBase)) {
- this.dtdListener.internalEntityDecl(var2, new String(var6));
- }
- }
- } else {
- if (var3 == this.entities && this.maybeWhitespace() && this.peek("NDATA")) {
- var4.notation = this.getMarkupDeclname("F-018", false);
- if (this.isValidating && this.notations.get(var4.notation) == null) {
- this.notations.put(var4.notation, Boolean.TRUE);
- }
- }
-
- var4.name = var2;
- var4.isPE = var3 == this.params;
- var4.isFromInternalSubset = this.inExternalPE ^ true;
- if (var5) {
- var3.put(var2, var4);
- if (var4.notation != null) {
- this.dtdHandler.unparsedEntityDecl(var2, var4.publicId, var4.systemId, var4.notation);
- } else if (var3 == this.entities) {
- this.dtdListener.externalEntityDecl(var2, var4.publicId, var4.systemId);
- }
- }
- }
-
- this.maybeWhitespace();
- this.nextChar('>', "F-031", var2);
- if (this.isValidating && var1 != this.field_0) {
- this.error("V-013", (Object[])null);
- }
-
- return true;
- }
- }
-
- private ExternalEntity maybeExternalID() throws IOException, SAXException {
- String var1 = null;
- if (this.peek("PUBLIC")) {
- this.whitespace("F-009");
- var1 = this.parsePublicId();
- } else if (!this.peek("SYSTEM")) {
- return null;
- }
-
- ExternalEntity var2 = new ExternalEntity(this.field_0);
- var2.publicId = var1;
- this.whitespace("F-008");
- var2.systemId = this.parseSystemId();
- return var2;
- }
-
- private String maybeGetName() throws IOException, SAXException {
- NameCacheEntry var1 = this.maybeGetNameCacheEntry();
- return var1 == null ? null : var1.name;
- }
-
- private NameCacheEntry maybeGetNameCacheEntry() throws IOException, SAXException {
- char var1 = this.getc();
- if (!XmlChars.isLetter(var1) && var1 != ':' && var1 != '_') {
- this.ungetc();
- return null;
- } else {
- return this.nameCharString(var1);
- }
- }
-
- private boolean maybeMarkupDecl() throws IOException, SAXException {
- return this.maybeElementDecl() || this.maybeAttlistDecl() || this.maybeEntityDecl() || this.maybeNotationDecl() || this.maybePI(false) || this.maybeComment(false);
- }
-
- private void maybeMisc(boolean var1) throws IOException, SAXException {
- while(!var1 || !this.field_0.isEOF()) {
- if (!this.maybeComment(false) && !this.maybePI(false) && !this.maybeWhitespace()) {
- break;
- }
- }
-
- }
-
- private boolean maybeNotationDecl() throws IOException, SAXException {
- InputEntity var1 = this.peekDeclaration("!NOTATION");
- if (var1 == null) {
- return false;
- } else {
- String var2 = this.getMarkupDeclname("F-019", false);
- ExternalEntity var3 = new ExternalEntity(this.field_0);
- this.whitespace("F-011");
- if (this.peek("PUBLIC")) {
- this.whitespace("F-009");
- var3.publicId = this.parsePublicId();
- if (this.maybeWhitespace()) {
- if (!this.peek(">")) {
- var3.systemId = this.parseSystemId();
- } else {
- this.ungetc();
- }
- }
- } else if (this.peek("SYSTEM")) {
- this.whitespace("F-008");
- var3.systemId = this.parseSystemId();
- } else {
- this.fatal("P-062");
- }
-
- this.maybeWhitespace();
- this.nextChar('>', "F-032", var2);
- if (this.isValidating && var1 != this.field_0) {
- this.error("V-013", (Object[])null);
- }
-
- if (var3.systemId != null && var3.systemId.indexOf(35) != -1) {
- this.error("P-056", new Object[]{var3.systemId});
- }
-
- Object var4 = this.notations.get(var2);
- if (var4 != null && var4 instanceof ExternalEntity) {
- this.warning("P-063", new Object[]{var2});
- } else if (!this.ignoreDeclarations) {
- this.notations.put(var2, var3);
- this.dtdHandler.notationDecl(var2, var3.publicId, var3.systemId);
- }
-
- return true;
- }
- }
-
- private boolean maybePEReference() throws IOException, SAXException {
- if (!this.field_0.peekc('%')) {
- return false;
- } else {
- String var1 = this.maybeGetName();
- if (var1 == null) {
- this.fatal("P-011");
- }
-
- this.nextChar(';', "F-021", var1);
- Object var2 = this.params.get(var1);
- if (var2 instanceof InternalEntity) {
- InternalEntity var3 = (InternalEntity)var2;
- this.pushReader(var3.buf, var1, false);
- } else if (var2 instanceof ExternalEntity) {
- this.externalParameterEntity((ExternalEntity)var2);
- } else if (var2 == null) {
- this.ignoreDeclarations = true;
- if (this.isValidating) {
- this.error("V-022", new Object[]{var1});
- } else {
- this.warning("V-022", new Object[]{var1});
- }
- }
-
- return true;
- }
- }
-
- private boolean maybePI(boolean var1) throws IOException, SAXException {
- boolean var2 = this.doLexicalPE;
- if (!this.field_0.peek(var1 ? "?" : "<?", (char[])null)) {
- return false;
- } else {
- this.doLexicalPE = false;
- String var3 = this.maybeGetName();
- if (var3 == null) {
- this.fatal("P-018");
- }
-
- if ("xml".equals(var3)) {
- this.fatal("P-019");
- }
-
- if ("xml".equalsIgnoreCase(var3)) {
- this.fatal("P-020", new Object[]{var3});
- }
-
- if (this.maybeWhitespace()) {
- this.strTmp = new StringBuffer();
-
- try {
- while(true) {
- char var4 = this.field_0.getc();
- if (var4 == '?' && this.field_0.peekc('>')) {
- break;
- }
-
- this.strTmp.append(var4);
- }
- } catch (EndOfInputException var5) {
- this.fatal("P-021");
- }
-
- this.docHandler.processingInstruction(var3, this.strTmp.toString());
- } else {
- if (!this.field_0.peek("?>", (char[])null)) {
- this.fatal("P-022");
- }
-
- this.docHandler.processingInstruction(var3, "");
- }
-
- this.doLexicalPE = var2;
- return true;
- }
- }
-
- private String maybeReadAttribute(String var1, boolean var2) throws IOException, SAXException {
- if (!this.maybeWhitespace()) {
- if (!var2) {
- return null;
- }
-
- this.fatal("P-024", new Object[]{var1});
- }
-
- if (!this.peek(var1)) {
- if (!var2) {
- this.ungetc();
- return null;
- }
-
- this.fatal("P-024", new Object[]{var1});
- }
-
- this.maybeWhitespace();
- this.nextChar('=', "F-023", (String)null);
- this.maybeWhitespace();
- return this.getQuotedString("F-035", var1);
- }
-
- private boolean maybeReferenceInContent(ElementDecl var1, ElementValidator var2) throws IOException, SAXException {
- if (!this.field_0.peekc('&')) {
- return false;
- } else if (!this.field_0.peekc('#')) {
- String var3 = this.maybeGetName();
- if (var3 == null) {
- this.fatal("P-009");
- }
-
- this.nextChar(';', "F-020", var3);
- this.expandEntityInContent(var1, var3, var2);
- return true;
- } else {
- var2.text();
- this.docHandler.characters(this.charTmp, 0, this.surrogatesToCharTmp(this.parseCharNumber()));
- return true;
- }
- }
-
- private void maybeTextDecl() throws IOException, SAXException {
- if (this.peek("<?xml")) {
- this.readVersion(false, "1.0");
- this.readEncoding(true);
- this.maybeWhitespace();
- if (!this.peek("?>")) {
- this.fatal("P-057");
- }
- }
-
- }
-
- private boolean maybeWhitespace() throws IOException, SAXException {
- if (this.inExternalPE && this.doLexicalPE) {
- char var1 = this.getc();
-
- boolean var2;
- for(var2 = false; var1 == ' ' || var1 == '\t' || var1 == '\n' || var1 == '\r'; var1 = this.getc()) {
- var2 = true;
- if (this.field_0.isEOF() && !this.field_0.isInternal()) {
- return var2;
- }
- }
-
- this.ungetc();
- return var2;
- } else {
- return this.field_0.maybeWhitespace();
- }
- }
-
- private void maybeXmlDecl() throws IOException, SAXException {
- if (this.peek("<?xml")) {
- this.readVersion(true, "1.0");
- this.readEncoding(false);
- this.readStandalone();
- this.maybeWhitespace();
- if (!this.peek("?>")) {
- char var1 = this.getc();
- this.fatal("P-023", new Object[]{Integer.toHexString(var1), new Character(var1)});
- }
-
- }
- }
-
- private NameCacheEntry nameCharString(char var1) throws IOException, SAXException {
- int var2 = 1;
-
- for(this.nameTmp[0] = var1; (var1 = this.field_0.getNameChar()) != 0; this.nameTmp[var2++] = var1) {
- if (var2 >= this.nameTmp.length) {
- char[] var3 = new char[this.nameTmp.length + 10];
- System.arraycopy(this.nameTmp, 0, var3, 0, this.nameTmp.length);
- this.nameTmp = var3;
- }
- }
-
- return this.nameCache.lookupEntry(this.nameTmp, var2);
- }
-
- ContentModel newContentModel(char var1, ContentModel var2) {
- return null;
- }
-
- ContentModel newContentModel(String var1) {
- return null;
- }
-
- ElementValidator newValidator(ElementDecl var1) {
- return ElementValidator.ANY;
- }
-
- private void nextChar(char var1, String var2, String var3) throws IOException, SAXException {
- while(this.field_0.isEOF() && !this.field_0.isDocument()) {
- this.field_0 = this.field_0.pop();
- }
-
- if (!this.field_0.peekc(var1)) {
- this.fatal("P-008", new Object[]{new Character(var1), messages.getMessage(this.locale, var2), var3 == null ? "" : '"' + var3 + '"'});
- }
-
- }
-
- private String normalize(boolean var1) throws SAXException {
- String var2 = this.strTmp.toString();
- String var3 = var2.trim();
- boolean var4 = false;
- if (var2 != var3) {
- var2 = var3;
- var3 = null;
- var4 = true;
- }
-
- this.strTmp = new StringBuffer();
-
- for(int var5 = 0; var5 < var2.length(); ++var5) {
- char var6 = var2.charAt(var5);
- if (!XmlChars.isSpace(var6)) {
- this.strTmp.append(var6);
- } else {
- this.strTmp.append(' ');
-
- while(true) {
- ++var5;
- if (var5 >= var2.length() || !XmlChars.isSpace(var2.charAt(var5))) {
- --var5;
- break;
- }
-
- var4 = true;
- }
- }
- }
-
- if (this.isValidating && this.isStandalone && var1 && (var3 == null || var4)) {
- this.error("V-019", (Object[])null);
- }
-
- if (var4) {
- return this.strTmp.toString();
- } else {
- return var2;
- }
- }
-
- public void parse(String var1) throws SAXException, IOException {
- this.init();
- InputSource var2 = this.resolver.resolveEntity((String)null, var1);
- if (var2 == null) {
- var2 = Resolver.createInputSource(new URL(var1), false);
- } else if (var2.getSystemId() == null) {
- this.warning("P-065", (Object[])null);
- var2.setSystemId(var1);
- }
-
- this.parseInternal(var2);
- }
-
- public void parse(InputSource var1) throws SAXException, IOException {
- this.init();
- this.parseInternal(var1);
- }
-
- private int parseCharNumber() throws SAXException, IOException {
- int var2 = 0;
- if (this.getc() != 'x') {
- this.ungetc();
-
- while(true) {
- char var3 = this.getc();
- if (var3 >= '0' && var3 <= '9') {
- var2 *= 10;
- var2 += var3 - 48;
- } else {
- if (var3 == ';') {
- return var2;
- }
-
- this.fatal("P-049");
- }
- }
- } else {
- while(true) {
- char var1 = this.getc();
- if (var1 >= '0' && var1 <= '9') {
- var2 <<= 4;
- var2 += var1 - 48;
- } else if (var1 >= 'a' && var1 <= 'f') {
- var2 <<= 4;
- var2 += 10 + (var1 - 97);
- } else if (var1 >= 'A' && var1 <= 'F') {
- var2 <<= 4;
- var2 += 10 + (var1 - 65);
- } else {
- if (var1 == ';') {
- return var2;
- }
-
- this.fatal("P-050");
- }
- }
- }
- }
-
- private void parseInternal(InputSource var1) throws SAXException, IOException {
- if (var1 == null) {
- this.fatal("P-000");
- }
-
- try {
- this.field_0 = InputEntity.getInputEntity(this.errHandler, this.locale);
- this.field_0.init(var1, (String)null, (InputEntity)null, false);
- this.docHandler.setDocumentLocator(this.locator);
- this.docHandler.startDocument();
- this.maybeXmlDecl();
- this.maybeMisc(false);
- if (!this.maybeDoctypeDecl() && this.isValidating) {
- this.warning("V-001", (Object[])null);
- }
-
- this.maybeMisc(false);
- this.donePrologue = true;
- if (!this.field_0.peekc('<') || !this.maybeElement((ElementValidator)null)) {
- this.fatal("P-067");
- }
-
- this.afterRoot();
- this.maybeMisc(true);
- if (!this.field_0.isEOF()) {
- this.fatal("P-001", new Object[]{Integer.toHexString(this.getc())});
- }
-
- this.docHandler.endDocument();
- } catch (EndOfInputException var9) {
- if (!this.field_0.isDocument()) {
- String var5 = this.field_0.getName();
-
- do {
- this.field_0 = this.field_0.pop();
- } while(this.field_0.isInternal());
-
- this.fatal("P-002", new Object[]{var5}, var9);
- } else {
- this.fatal("P-003", (Object[])null, var9);
- }
- } catch (RuntimeException var10) {
- throw new SAXParseException(((Throwable)var10).getMessage() != null ? ((Throwable)var10).getMessage() : var10.getClass().getName(), this.locator.getPublicId(), this.locator.getSystemId(), this.locator.getLineNumber(), this.locator.getColumnNumber(), var10);
- } finally {
- this.strTmp = null;
- this.attTmp = null;
- this.nameTmp = null;
- this.nameCache = null;
- if (this.field_0 != null) {
- this.field_0.close();
- this.field_0 = null;
- }
-
- this.params.clear();
- this.entities.clear();
- this.notations.clear();
- this.elements.clear();
- this.afterDocument();
- }
-
- }
-
- private void parseLiteral(boolean var1) throws IOException, SAXException {
- char var2 = this.getc();
- InputEntity var4 = this.field_0;
- if (var2 != '\'' && var2 != '"') {
- this.fatal("P-007");
- }
-
- this.isInAttribute = var1 ^ true;
- this.strTmp = new StringBuffer();
-
- while(true) {
- while(this.field_0 == var4 || !this.field_0.isEOF()) {
- char var3;
- if ((var3 = this.getc()) == var2 && this.field_0 == var4) {
- this.isInAttribute = false;
- return;
- }
-
- if (var3 == '&') {
- String var7 = this.maybeGetName();
- if (var7 != null) {
- this.nextChar(';', "F-020", var7);
- if (var1) {
- this.strTmp.append('&');
- this.strTmp.append(var7);
- this.strTmp.append(';');
- } else {
- this.expandEntityInLiteral(var7, this.entities, var1);
- }
- } else if (this.getc() == '#') {
- int var6 = this.parseCharNumber();
- if (var6 > 65535) {
- var6 = this.surrogatesToCharTmp(var6);
- this.strTmp.append(this.charTmp[0]);
- if (var6 == 2) {
- this.strTmp.append(this.charTmp[1]);
- }
- } else {
- this.strTmp.append((char)var6);
- }
- } else {
- this.fatal("P-009");
- }
- } else {
- if (var3 == '%' && var1) {
- String var5 = this.maybeGetName();
- if (var5 != null) {
- this.nextChar(';', "F-021", var5);
- if (this.inExternalPE) {
- this.expandEntityInLiteral(var5, this.params, var1);
- } else {
- this.fatal("P-010", new Object[]{var5});
- }
- continue;
- }
-
- this.fatal("P-011");
- }
-
- if (!var1) {
- if (var3 == ' ' || var3 == '\t' || var3 == '\n' || var3 == '\r') {
- this.strTmp.append(' ');
- continue;
- }
-
- if (var3 == '<') {
- this.fatal("P-012");
- }
- }
-
- this.strTmp.append(var3);
- }
- }
-
- this.field_0 = this.field_0.pop();
- }
- }
-
- private String parsePublicId() throws IOException, SAXException {
- String var1 = this.getQuotedString("F-033", (String)null);
-
- for(int var2 = 0; var2 < var1.length(); ++var2) {
- char var3 = var1.charAt(var2);
- if (" \r\n-'()+,./:=?;!*#@$_%0123456789".indexOf(var3) == -1 && (var3 < 'A' || var3 > 'Z') && (var3 < 'a' || var3 > 'z')) {
- this.fatal("P-016", new Object[]{new Character(var3)});
- }
- }
-
- this.strTmp = new StringBuffer();
- this.strTmp.append(var1);
- return this.normalize(false);
- }
-
- private String parseSystemId() throws IOException, SAXException {
- String var1 = this.getQuotedString("F-034", (String)null);
- int var2 = var1.indexOf(58);
- if (var2 == -1 || var1.indexOf(47) < var2) {
- String var3 = this.field_0.getSystemId();
- if (var3 == null) {
- this.fatal("P-055", new Object[]{var1});
- }
-
- if (var1.length() == 0) {
- var1 = ".";
- }
-
- var3 = var3.substring(0, var3.lastIndexOf(47) + 1);
- if (var1.charAt(0) == '/') {
- throw new InternalError();
- }
-
- var1 = var3 + var1;
- }
-
- if (var1.indexOf(35) != -1) {
- this.error("P-056", new Object[]{var1});
- }
-
- return var1;
- }
-
- private boolean peek(String var1) throws IOException, SAXException {
- return this.field_0.peek(var1, (char[])null);
- }
-
- private InputEntity peekDeclaration(String var1) throws IOException, SAXException {
- if (!this.field_0.peekc('<')) {
- return null;
- } else {
- InputEntity var2 = this.field_0;
- if (this.field_0.peek(var1, (char[])null)) {
- return var2;
- } else {
- this.field_0.ungetc();
- return null;
- }
- }
- }
-
- public void pushInputBuffer(char[] var1, int var2, int var3) throws SAXException {
- if (var3 > 0) {
- if (var2 != 0 || var3 != var1.length) {
- char[] var4 = new char[var3];
- System.arraycopy(var1, var2, var4, 0, var3);
- var1 = var4;
- }
-
- this.pushReader(var1, (String)null, false);
- }
- }
-
- private boolean pushReader(ExternalEntity var1) throws SAXException, IOException {
- if (!var1.isPE && !this.isInAttribute) {
- this.lexicalListener.startParsedEntity(var1.name);
- }
-
- InputEntity var2 = InputEntity.getInputEntity(this.errHandler, this.locale);
- InputSource var3 = var1.getInputSource(this.resolver);
- var2.init(var3, var1.name, this.field_0, var1.isPE);
- this.field_0 = var2;
- return true;
- }
-
- private void pushReader(char[] var1, String var2, boolean var3) throws SAXException {
- if (var3 && !this.isInAttribute) {
- this.lexicalListener.startParsedEntity(var2);
- }
-
- InputEntity var4 = InputEntity.getInputEntity(this.errHandler, this.locale);
- var4.init(var1, var2, this.field_0, var3 ^ true);
- this.field_0 = var4;
- }
-
- private void readEncoding(boolean var1) throws IOException, SAXException {
- String var2 = this.maybeReadAttribute("encoding", var1);
- if (var2 != null) {
- for(int var3 = 0; var3 < var2.length(); ++var3) {
- char var4 = var2.charAt(var3);
- if ((var4 < 'A' || var4 > 'Z') && (var4 < 'a' || var4 > 'z') && (var3 == 0 || (var4 < '0' || var4 > '9') && var4 != '-' && var4 != '_' && var4 != '.')) {
- this.fatal("P-060", new Object[]{new Character(var4)});
- }
- }
-
- String var5 = this.field_0.getEncoding();
- if (var5 != null && !var2.equalsIgnoreCase(var5)) {
- this.warning("P-061", new Object[]{var2, var5});
- }
-
- }
- }
-
- private void readStandalone() throws IOException, SAXException {
- String var1 = this.maybeReadAttribute("standalone", false);
- if (var1 != null && !"no".equals(var1)) {
- if ("yes".equals(var1)) {
- this.isStandalone = true;
- } else {
- this.fatal("P-029", new Object[]{var1});
- }
- }
- }
-
- private void readVersion(boolean var1, String var2) throws IOException, SAXException {
- String var3 = this.maybeReadAttribute("version", var1);
- if (var1 && var3 == null) {
- this.fatal("P-025", new Object[]{var2});
- }
-
- if (var3 != null) {
- int var4 = var3.length();
-
- for(int var5 = 0; var5 < var4; ++var5) {
- char var6 = var3.charAt(var5);
- if ((var6 < '0' || var6 > '9') && var6 != '_' && var6 != '.' && (var6 < 'a' || var6 > 'z') && (var6 < 'A' || var6 > 'Z') && var6 != ':' && var6 != '-') {
- this.fatal("P-026", new Object[]{var3});
- }
- }
- }
-
- if (var3 != null && !var3.equals(var2)) {
- this.error("P-027", new Object[]{var2, var3});
- }
-
- }
-
- public void setDTDHandler(DTDHandler var1) {
- if (var1 == null) {
- var1 = defaultHandler;
- }
-
- this.dtdHandler = (DTDHandler)var1;
- if (var1 instanceof DtdEventListener) {
- this.dtdListener = (DtdEventListener)var1;
- } else {
- this.dtdListener = defaultHandler;
- }
-
- }
-
- public void setDocumentHandler(DocumentHandler var1) {
- if (var1 == null) {
- var1 = defaultHandler;
- }
-
- this.docHandler = (DocumentHandler)var1;
- if (var1 instanceof LexicalEventListener) {
- this.lexicalListener = (LexicalEventListener)var1;
- } else {
- this.lexicalListener = defaultHandler;
- }
-
- }
-
- public void setEntityResolver(EntityResolver var1) {
- this.resolver = var1;
- }
-
- public void setErrorHandler(ErrorHandler var1) {
- this.errHandler = var1;
- }
-
- public void setFastStandalone(boolean var1) {
- this.fastStandalone = var1 && !this.isValidating;
- }
-
- private void setHandlers() {
- if (this.dtdHandler == null) {
- this.dtdHandler = defaultHandler;
- }
-
- if (this.dtdListener == null) {
- this.dtdListener = defaultHandler;
- }
-
- if (this.errHandler == null) {
- this.errHandler = defaultHandler;
- }
-
- if (this.docHandler == null) {
- this.docHandler = defaultHandler;
- }
-
- if (this.lexicalListener == null) {
- this.lexicalListener = defaultHandler;
- }
-
- }
-
- void setIsValidating(boolean var1) {
- this.isValidating = var1;
- if (var1) {
- this.fastStandalone = false;
- }
-
- }
-
- public void setLocale(Locale var1) throws SAXException {
- if (var1 != null && !messages.isLocaleSupported(var1.toString())) {
- throw new SAXException(messages.getMessage(this.locale, "P-078", new Object[]{var1}));
- } else {
- this.locale = var1;
- }
- }
-
- private int surrogatesToCharTmp(int var1) throws SAXException {
- if (var1 <= 65535) {
- if (XmlChars.isChar(var1)) {
- this.charTmp[0] = (char)var1;
- return 1;
- }
- } else if (var1 <= 1114111) {
- var1 -= 65536;
- this.charTmp[0] = (char)('\ud800' | var1 >> 10 & 1023);
- this.charTmp[1] = (char)('\udc00' | var1 & 1023);
- return 2;
- }
-
- this.fatal("P-051", new Object[]{Integer.toHexString(var1)});
- return -1;
- }
-
- private void ungetc() {
- this.field_0.ungetc();
- }
-
- void validateAttributeSyntax(AttributeDecl var1, String var2) throws SAXException {
- }
-
- private void warning(String var1, Object[] var2) throws SAXException {
- SAXParseException var3 = new SAXParseException(messages.getMessage(this.locale, var1, var2), this.locator);
- this.errHandler.warning(var3);
- }
-
- private void whitespace(String var1) throws IOException, SAXException {
- if (!this.maybeWhitespace()) {
- this.fatal("P-004", new Object[]{messages.getMessage(this.locale, var1)});
- }
-
- }
- }
-